package com.example.springbasicstudy.startupInterface;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;

import java.time.LocalDateTime;

/**
 * <pre>
 * 功能描述：
 * </pre>
 *
 * @author: 李明杰
 * @date: 2023/3/27 11:28
 */
@Slf4j
public class MySpringApplicationRunListener implements SpringApplicationRunListener {
    private final SpringApplication application;
    private final String[] args;

    public MySpringApplicationRunListener(SpringApplication sa, String[] args) {
        this.application = sa;
        this.args = args;
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        log.error("contextPrepared {}", LocalDateTime.now());
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        log.error("contextLoaded {}", LocalDateTime.now());
    }

    @Override
    public void started(ConfigurableApplicationContext context) {
        log.error("started {}", LocalDateTime.now());
    }

    @Override
    public void running(ConfigurableApplicationContext context) {
        log.error("running {}", LocalDateTime.now());
    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {
        log.error("failed {}", LocalDateTime.now());
    }

    @Override
    public void starting(ConfigurableBootstrapContext bootstrapContext) {
        log.error("starting {}", LocalDateTime.now());
    }

}